package com.mobilous.client.MainScreen;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.mobilous.client.StaticData;

public class MainPage extends Composite {
	public static Image helpicon;
	public static Button btnPeople;
	public static Button btnappsbutton;
	public MainPage() {
		StaticData.absolutePanel.clear();
		StaticData.absolutePanelMenuBar.clear();
		StaticData.absolutePanelMenuBar.setStyleName("gwt-background");
		StaticData.absolutePanel.add(StaticData.absolutePanelMenuBar, 0, 0);
		StaticData.absolutePanelMenuBar.setSize("1024px", "45px");

		btnappsbutton = new Button("appsbutton");
		StaticData.absolutePanelMenuBar.add(btnappsbutton, 10, 10);
		//btnappsbutton.setSize("56px", "30px");
		btnappsbutton.setText("Apps");
		btnappsbutton.setEnabled(false);

		helpicon = new Image("images/helpicon.png");
		StaticData.absolutePanelMenuBar.add(helpicon, 982, 10);
		helpicon.setSize("32px", "32px");
		//StaticData.absolutePanel.set
		btnPeople = new Button("People");
		StaticData.absolutePanelMenuBar.add(btnPeople, 72, 10);

		btnPeople.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				btnappsbutton.setEnabled(true);
				btnPeople.setEnabled(false);
				StaticData.absolutePanelMainBody.clear();
				StaticData.absolutePanelMainBody.add(StaticData.people);
			}
		});

		btnappsbutton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				btnappsbutton.setEnabled(false);
				btnPeople.setEnabled(true);
				StaticData.absolutePanelMainBody.clear();
				StaticData.absolutePanelMainBody.add(StaticData.appslist);
			}
		});

		StaticData.absolutePanelMainBody.clear();
		StaticData.absolutePanel.add(StaticData.absolutePanelMainBody, 0, 45);
		StaticData.absolutePanelMainBody.setSize("1024px", "722px");
		AppsList appsList = new AppsList();
		appsList.setStyleName("gtw-forground");
		StaticData.absolutePanelMainBody.add(appsList);
		StaticData.people=new People();
		StaticData.appslist= new AppsList();
		help();

		MainPage.helpicon.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				dialogBox.show();
			}
		});
	}

	private DialogBox dialogBox = new DialogBox();
	void help()
	{
		// Create the popup dialog box

		dialogBox.setText("Need Assistance");
		dialogBox.setAnimationEnabled(true);
		final Button closeButton = new Button("Close");
		closeButton.getElement().setId("closeButton");
		VerticalPanel dialogVPanel = new VerticalPanel();
		dialogVPanel.addStyleName("dialogVPanel");
		dialogVPanel.add(new HTML("<b>My Apps</b>"));
		dialogVPanel.add(new HTML("This is to help you find your way around this mess."));
		dialogVPanel.add(new HTML("<b>People</b>"));
		dialogVPanel.add(new HTML("This is to help you find your way around this mess."));
		dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
		dialogVPanel.add(closeButton);
		dialogBox.setWidget(dialogVPanel);
		dialogBox.center();
		// Add a handler to close the DialogBox
		closeButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				dialogBox.hide();
			}
		});
		dialogBox.hide();
	}
}
